API Documentation
Matrix.h
1 // Matrix.h
3 //
5 
6 namespace nkMaths
7 {
13  class Matrix : public ByteAlignedClass<16>
14  {
15  public :
16 
17  // Attributes
18  float _m [4][4] ;
19 
20  public :
21 
26  Matrix () ;
38  Matrix (float m00, float m01, float m10, float m11) ;
55  Matrix (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) ;
78  Matrix (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) ;
84  Matrix (const Matrix& other) ;
85 
86  // Getters
90  Vector getRow0 () const ;
94  Vector getRow1 () const ;
98  Vector getRow2 () const ;
102  Vector getRow3 () const ;
106  Vector getCol0 () const ;
110  Vector getCol1 () const ;
114  Vector getCol2 () const ;
118  Vector getCol3 () const ;
127  float get (unsigned int row, unsigned int col) const ;
128 
129  // Setters
139  Matrix& set (float val, unsigned int row, unsigned int col) ;
140 
141  // Alterations
157  Matrix getTranspose () const ;
182 
183  // Transformations
209  void getDecomposed (Vector& position, Quaternion& orientation, Vector& scale) ;
210 
219  Matrix& setToViewMatrixDirection (const Vector& position, const Vector& direction, const Vector& upDirection) ;
232  Matrix& setToPerspectiveMatrix (float fov, float aspect, float nearVal, float farVal) ;
245  Matrix& setToOrthographicMatrix (float widthNearPlane, float heightNearPlane, float nearVal, float farVal) ;
252  Matrix& setPositionComponent (const Vector& position) ;
266  Matrix& setScaleComponent (const Vector& scale) ;
275  Matrix& setToTransformation (const Vector& position, const Quaternion& orientation, const Vector& scale) ;
276 
277  // Utilities
281  float getDeterminantMat2 () const ;
285  float getDeterminantMat3 () const ;
289  float getDeterminantMat4 () const ;
293  float getTraceMat3 () const ;
297  float getTraceMat3 () const ;
301  float getTraceMat4 () const ;
302 
312 
313  // Operators
320  Matrix& operator= (const Matrix& other) ;
327  bool operator== (const Matrix& other) ;
334  bool operator!= (const Matrix& other) ;
341  Matrix operator+ (const Matrix& other) const ;
347  void operator+= (const Matrix& other) ;
354  Matrix operator- (const Matrix& other) const ;
360  void operator-= (const Matrix& other) ;
367  Matrix operator* (const Matrix& other) const ;
374  Vector operator* (const Vector& toApply) const ;
383  Quaternion operator* (const Quaternion& toApply) const ;
390  Matrix operator* (float scalar) const ;
396  void operator*= (const Matrix& other) ;
402  void operator*= (float scalar) ;
409  Matrix operator/ (float scalar) const ;
415  void operator /= (float scalar) ;
416  } ;
417 }
nkMaths::Matrix::getTraceMat4
float getTraceMat4() const
nkMaths::Matrix::setToPerspectiveMatrix
Matrix & setToPerspectiveMatrix(float fov, float aspect, float nearVal, float farVal)
nkMaths::Matrix::operator!=
bool operator!=(const Matrix &other)
nkMaths::Matrix::getInverseMat3
Matrix getInverseMat3() const
nkMaths::Matrix::getDecomposed
void getDecomposed(Vector &position, Quaternion &orientation, Vector &scale)
nkMaths::Matrix::inverseMat4
Matrix & inverseMat4()
nkMaths::Matrix::getInverseMat4
Matrix getInverseMat4() const
nkMaths::Matrix::setOrientationComponent
Matrix & setOrientationComponent(const Quaternion &rot)
nkMaths::Matrix::operator*
Matrix operator*(const Matrix &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Matrix::transpose
Matrix & transpose()
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Matrix::getCol1
Vector getCol1() const
nkMaths::Matrix::setScaleComponent
Matrix & setScaleComponent(const Vector &scale)
nkMaths::Matrix::getCol0
Vector getCol0() const
nkMaths::Matrix::getTraceMat3
float getTraceMat3() const
nkMaths::Matrix::getRow3
Vector getRow3() const
nkMaths::Matrix::getRow2
Vector getRow2() const
nkMaths::Matrix::_m
float _m[4][4]
The matrix memory, considered in row-major order (_m[row][col]).
Definition: Matrix.h:18
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Matrix::operator-=
void operator-=(const Matrix &other)
nkMaths::Matrix::getScaleComponent
Vector getScaleComponent() const
nkMaths::Matrix::Matrix
Matrix()
nkMaths::Matrix::getCol3
Vector getCol3() const
nkMaths::Matrix::inverseMat3
Matrix & inverseMat3()
nkMaths::Matrix::operator==
bool operator==(const Matrix &other)
nkMaths::Matrix::getCol2
Vector getCol2() const
nkMaths::Matrix::operator/=
void operator/=(float scalar)
nkMaths::Matrix::setToViewMatrixDirection
Matrix & setToViewMatrixDirection(const Vector &position, const Vector &direction, const Vector &upDirection)
nkMaths::Matrix::getDeterminantMat3
float getDeterminantMat3() const
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m10, float m11)
nkMaths::Matrix::setPositionComponent
Matrix & setPositionComponent(const Vector &position)
nkMaths::Matrix::getDeterminantMat4
float getDeterminantMat4() const
nkMaths::Matrix::setToOrthographicMatrix
Matrix & setToOrthographicMatrix(float widthNearPlane, float heightNearPlane, float nearVal, float farVal)
nkMaths::Matrix::getDeterminantMat2
float getDeterminantMat2() const
nkMaths::Matrix::operator+
Matrix operator+(const Matrix &other) const
nkMaths::Matrix::operator-
Matrix operator-(const Matrix &other) const
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkMaths::Matrix::setToTransformation
Matrix & setToTransformation(const Vector &position, const Quaternion &orientation, const Vector &scale)
nkMaths::Matrix::getRow0
Vector getRow0() const
nkMaths::Matrix::inverseMat2
Matrix & inverseMat2()
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
nkMaths::Matrix::getOrientationComponent
Matrix getOrientationComponent() const
nkMaths::Matrix::operator=
Matrix & operator=(const Matrix &other)
nkMaths::Matrix::Matrix
Matrix(const Matrix &other)
nkMaths::Matrix::getRow1
Vector getRow1() const
nkMaths::Matrix::fromString
Matrix & fromString(const nkMemory::StringView &str)
nkMaths::Matrix::getPositionComponent
Vector getPositionComponent() const
nkMaths::Matrix::operator*=
void operator*=(const Matrix &other)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Matrix::get
float get(unsigned int row, unsigned int col) const
nkMaths::Matrix::getTranspose
Matrix getTranspose() const
nkMaths::Matrix::set
Matrix & set(float val, unsigned int row, unsigned int col)
nkMaths::Matrix::operator/
Matrix operator/(float scalar) const
nkMaths::Matrix::getInverseMat2
Matrix getInverseMat2() const
nkMaths::Matrix::operator+=
void operator+=(const Matrix &other)